import {request} from '../utils/request.js'

const apiUrl = {
	//团长：开团、获取已开团、获取团信息、修改团公告、团员管理
	openGroup:'/group/addGroup',
	getGroupByOpen:'/group/getUserOpenGroupList',
	getGroupDetail:'/group/getGroupDetail',
	updateGroupNotice:'/group/updateGroup',
	getGroupMemberData:'/group/getGroupMemberData',//？
	//团员：查看已入的团、团员获取团信息、修改团公告
	getGroupByJoin:'/group/getGroupByJoin',
	joinGroup:'/group/joinGroup',
	removeJoin:'/group/removeJoin',
	//获取谷团推荐列表
	getApproveList:'/group/getApproveList',
	approve:'/group/approve',
	getGroupPage:'/group/getGroupPage'
}

export function openGroup(data) {
	return request(apiUrl.openGroup, 'POST', data)
}

export function getGroupByOpen(data) {
	return request(apiUrl.getGroupByOpen, 'GET')
}

export function getGroupDetail(data) {
	return request(`${apiUrl.getGroupDetail}?groupId=${data}`, 'GET')
}

export function updateGroupNotice(data) {
	return request(apiUrl.updateGroupNotice, 'PUT', data)
}

export function getGroupByJoin(data) {
	return request(`${apiUrl.getGroupByJoin}`, 'GET')
}

export function getGroupMemberData(data) {
	return request(`${apiUrl.getGroupMemberData}?groupId=${data}`, 'GET')
}

export function joinGroup(data) {
	return request(`${apiUrl.joinGroup}?groupId=${data}`, 'POST')
}

export function removeJoin(data) {
	return request(`${apiUrl.removeJoin}?groupId=${data}`, 'DELETE')
}

export function getApproveList(data) {
	return request(apiUrl.getApproveList, 'GET', data)
}

export function approve(data) {
	return request(apiUrl.approve, 'POST', data)
}

export function getGroupPage(data) {
	return request(apiUrl.getGroupPage, 'POST', data)
}